package com.huifaapp.mall.activity;



import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huifaapp.mall.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017-11-27.
 */

public class EarnMoneyFragment extends Fragment implements View.OnClickListener{
//    private  TabLayout tab_layout_earn;
//    private ViewPager viewpager;

    private List<String> mTitleList = new ArrayList<>();//页卡标题集合
    private View VerGame, VerSimple, VerHighCommission;//页卡视图
    private List<View> mViewList = new ArrayList<>();//页卡视图集合
    private LayoutInflater mInflater;

    private TextView details_youxi_tx,details_jiandan_tx,details_gaoyong_tx;
    private View index3,index1,index2;
    private LinearLayout ll_youxi,ll_jiandan,ll_gaoyong;
    private TextView tv_login;
    private Button tmallButten;
    private Button shopping_butten;
    private Button bt_dingdanxiangxing;
    private Button bt_zhengdiantemai;
    private Button bt_goshopping;
    private TextView tv_yaoqinglingxian;
    private TextView tv_yaoqingVIP;
    private TextView tv_meiribitui;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View viewLayout = inflater.inflate(R.layout.fragment_earn_money, container, false);
        tv_login = (TextView) viewLayout.findViewById(R.id.tv_login);
        tmallButten = (Button) viewLayout.findViewById(R.id.tmallButten);
        tv_yaoqinglingxian= (TextView) viewLayout.findViewById(R.id.tv_yaoqinglingxian);
        tv_meiribitui= (TextView) viewLayout.findViewById(R.id.tv_meiribitui);
        tv_meiribitui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),DailyWillPushActivity.class);
                startActivity(intent);

            }
        });
        bt_dingdanxiangxing= (Button) viewLayout.findViewById(R.id.bt_dingdanxiangxing);
        bt_dingdanxiangxing.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), DetailsofPaymentActivity.class);
                startActivity(intent);
            }
        });
        bt_zhengdiantemai= (Button) viewLayout.findViewById(R.id.bt_zhengdiantemai);
        bt_zhengdiantemai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), MinuteKillActivity.class);
                startActivity(intent);
            }
        });
        shopping_butten = (Button) viewLayout.findViewById(R.id.shopping_butten);
        shopping_butten.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ShoppingCartActivity.class);
                startActivity(intent);
            }
        });
        bt_goshopping= (Button) viewLayout.findViewById(R.id.bt_goshopping);
        bt_goshopping.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), ShopCartActivity.class);
                startActivity(intent);
            }
        });
        tmallButten.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TmallActivity.class);
                startActivity(intent);
            }
        });
        tv_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
            }
        });
        tv_yaoqinglingxian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), InviteCollarNowActivity.class);
                startActivity(intent);
            }
        });
        tv_yaoqingVIP= (TextView) viewLayout.findViewById(R.id.tv_yaoqingVIP);
        tv_yaoqingVIP.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(getActivity(),InvitationVIPActivity.class);
                startActivity(intent);
            }
        });

//    Intent intent = getActivity().getIntent();

    initView(viewLayout);
//        mInflater = LayoutInflater.from(getActivity());
//        VerGame = mInflater.inflate(R.layout.earn_ver_game, null);
//        VerSimple = mInflater.inflate(R.layout.earn_ver_simple, null);
//        VerHighCommission = mInflater.inflate(R.layout.earn_ver_highcommission, null);
//
//        //添加页卡视图
//        mViewList.add(VerGame);
//        mViewList.add(VerSimple);
//        mViewList.add(VerHighCommission);
//        //添加标题
//        mTitleList.add("游戏");
//        mTitleList.add("简单");
//        mTitleList.add("高佣");
//
//        tab_layout_earn.setTabMode(TabLayout.MODE_FIXED);//设置tab模式，当前为系统默认模式
//        tab_layout_earn.addTab(tab_layout_earn.newTab().setText(mTitleList.get(0)));//添加tab选项卡
//        tab_layout_earn.addTab(tab_layout_earn.newTab().setText(mTitleList.get(1)));
//        tab_layout_earn.addTab(tab_layout_earn.newTab().setText(mTitleList.get(2)));
//
//
//
//        EarnAdapter adapter = new EarnAdapter(mViewList,mTitleList);
//        viewpager.setAdapter(adapter);//给ViewPager设置适配器
//        tab_layout_earn.setupWithViewPager(viewpager);//将TabLayout和ViewPager关联起来。
//        tab_layout_earn.setTabsFromPagerAdapter(adapter);//给Tabs设置适配器

        return viewLayout;
}
    private void initView(View viewLayout) {
//        tab_layout_earn = (TabLayout) viewLayout.findViewById(R.id.tab_layout_eran);
//        viewpager = (ViewPager) viewLayout.findViewById(R.id.viewpager_earn);
        details_youxi_tx= (TextView) viewLayout.findViewById(R.id.details_youxi_tx);
        details_youxi_tx.setOnClickListener(this);
        details_jiandan_tx= (TextView) viewLayout.findViewById(R.id.details_jiandan_tx);
        details_jiandan_tx.setOnClickListener(this);
        details_gaoyong_tx= (TextView) viewLayout.findViewById(R.id.details_gaoyong_tx);
        details_gaoyong_tx.setOnClickListener(this);
        ll_youxi= (LinearLayout) viewLayout.findViewById(R.id.ll_youxi);
        ll_jiandan= (LinearLayout) viewLayout.findViewById(R.id.ll_jiandan);
        ll_gaoyong= (LinearLayout) viewLayout.findViewById(R.id.ll_gaoyong);
        index1= viewLayout.findViewById(R.id.details_xiahua1);
        index2= viewLayout.findViewById(R.id.details_xiahua2);
        index3= viewLayout.findViewById(R.id.details_xiahua3);
        index1.setBackgroundColor(Color.rgb(255, 0, 0));
        index2.setBackgroundColor(Color.rgb(255, 255, 255));
        index3.setBackgroundColor(Color.rgb(255, 255, 255));
        details_youxi_tx.setTextColor(Color.rgb(255, 59, 87));
        details_jiandan_tx.setTextColor(Color.rgb(105, 102, 102));
        details_gaoyong_tx.setTextColor(Color.rgb(105, 102, 102));
        ll_youxi.setVisibility(View.VISIBLE);
        ll_jiandan.setVisibility(View.GONE);
        ll_gaoyong.setVisibility(View.GONE);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.details_youxi_tx:
                index1.setBackgroundColor(Color.rgb(255, 0, 0));
                index2.setBackgroundColor(Color.rgb(255, 255, 255));
                index3.setBackgroundColor(Color.rgb(255, 255, 255));
                details_youxi_tx.setTextColor(Color.rgb(255, 59, 87));
                details_jiandan_tx.setTextColor(Color.rgb(105, 102, 102));
                details_gaoyong_tx.setTextColor(Color.rgb(105, 102, 102));
                ll_youxi.setVisibility(View.VISIBLE);
                ll_jiandan.setVisibility(View.GONE);
                ll_gaoyong.setVisibility(View.GONE);
                break;
            case R.id.details_jiandan_tx:
                ll_youxi.setVisibility(View.GONE);
                ll_jiandan.setVisibility(View.VISIBLE);
                ll_gaoyong.setVisibility(View.GONE);
                index2.setBackgroundColor(Color.rgb(255, 0, 0));
                index1.setBackgroundColor(Color.rgb(255, 255, 255));
                index3.setBackgroundColor(Color.rgb(255, 255, 255));
                details_jiandan_tx .setTextColor(Color.rgb(255, 59, 87));
                details_youxi_tx.setTextColor(Color.rgb(105, 102, 102));
                details_gaoyong_tx.setTextColor(Color.rgb(105, 102, 102));

                break;
            case R.id.details_gaoyong_tx:
                ll_youxi.setVisibility(View.GONE);
                ll_jiandan.setVisibility(View.GONE);
                ll_gaoyong.setVisibility(View.VISIBLE);
                index3.setBackgroundColor(Color.rgb(255, 0, 0));
                index2.setBackgroundColor(Color.rgb(255, 255, 255));
                index1.setBackgroundColor(Color.rgb(255, 255, 255));
                details_gaoyong_tx.setTextColor(Color.rgb(255, 59, 87));
                details_jiandan_tx.setTextColor(Color.rgb(105, 102, 102));
                details_youxi_tx.setTextColor(Color.rgb(105, 102, 102));
                break;
        }
    }
}
